import { IPSAppCounterRef } from '../control/ipsapp-counter-ref';
import { IPSAppViewUIAction } from './ipsapp-view-uiaction';
import { IPSUIAction } from '../../view/ipsuiaction';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppViewUIActionImpl extends PSModelObjectImpl implements IPSAppViewUIAction {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappcounterref: IPSAppCounterRef | null = null;

  getPSAppCounterRef(): IPSAppCounterRef | null {
    if (this.psappcounterref != null) return this.psappcounterref;
    const value = this.M.getPSAppCounterRef;
    if (value == null) {
      return null;
    }
    this.psappcounterref = this.getPSModel4('app.control.IPSAppCounterRef', value, 'getPSAppCounterRef') as IPSAppCounterRef;
    return this.psappcounterref;
  }

  get psAppCounterRef(): IPSAppCounterRef | null {
    return this.getPSAppCounterRef();
  }

  getPSAppCounterRefMust(): IPSAppCounterRef {
    const value = this.getPSAppCounterRef();
    if (value == null) {
      throw new Error('未指定应用计数器引用');
    }
    return value;
  }

  protected psuiaction: IPSUIAction | null = null;

  getPSUIAction(): IPSUIAction | null {
    if (this.psuiaction != null) return this.psuiaction;
    const value = this.M.getPSUIAction;
    if (value == null) {
      return null;
    }
    this.psuiaction = this.getPSModel4('view.IPSUIAction', value, 'getPSUIAction') as IPSUIAction;
    return this.psuiaction;
  }

  get psUIAction(): IPSUIAction | null {
    return this.getPSUIAction();
  }

  getPSUIActionMust(): IPSUIAction {
    const value = this.getPSUIAction();
    if (value == null) {
      throw new Error('未指定界面行为对象');
    }
    return value;
  }

  get uIActionParamJO(): IModel {
    return this.M.uIActionParamJO;
  }

  get uIActionTarget(): 'SINGLEDATA' | 'SINGLEKEY' | 'MULTIDATA' | 'MULTIKEY' | 'NONE' {
    return this.M.uIActionTarget;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get xDataControlName(): string {
    return this.M.xDataControlName;
  }

  get saveTargetFirst(): boolean {
    return this.M.saveTargetFirst != null ? this.M.saveTargetFirst : false;
  }

  get cls(): string {
    return 'PSAppViewUIActionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.view.IPSAppViewUIAction') return true;
    return super.instanceof(cls);
  }
}
